#!/bin/bash
baseDirForScriptSelf=$(cd "$(dirname "$0")"; pwd)
if [ -f ~/.pip/pip.conf ];then
    mv ~/.pip/pip.conf ~/.pip/pip.conf_`date '+%s'`
fi

# 配置pip源
if [ ! -d ~/.pip ];then
    mkdir -p ~/.pip
fi


unset http_proxy
unset https_proxy
is_huawei_tmp=`curl -I -m 10 -o /dev/null -s -w %{http_code} w3.huawei.com`
if [ "${is_huawei_tmp}" == "200" ];then
    is_huawei=true
else
    is_huawei=false
fi
# 请根据实际情况修改pip源配置
if [ "${is_huawei}" == "true" ];then
    echo '''[global]
index-url = http://mirrors.tools.huawei.com/pypi/simple
trusted-host = mirrors.tools.huawei.com
timeout = 120'''>~/.pip/pip.conf
else
    echo '''[global]
timeout=6000
index-url = http://mirrors.aliyun.com/pypi/simple
trusted-host = mirrors.aliyun.com'''>~/.pip/pip.conf
fi